package com.example.demo.calc;

public class ShiftCompute {

    /**
     * 唯一运算
     *  对于右移大于或等于位宽的操作，或者右移负数的操作，其结果将依赖于编译器的处理和硬件指令的处理，并不唯一
     * @param args
     */
    public static void main(String[] args) {
        int num = 3;
        System.out.println(num << 3);
        System.out.println(num >> 31);
        System.out.println(num >> 32);

        int num2 = 24;
        System.out.println(num2 >> 2);
        System.out.println(num2 << 32);
        System.out.println(num2 >> 32);

        System.out.println("=======================");
        int aa = 0x0FFF;
        String ss = Integer.toBinaryString(aa);
        System.out.println(ss);

        System.out.println("=======================");
        long num3 = 35;
        System.out.println(num3 << 64);
        System.out.println(num3 >> 64);

        System.out.println("=======================");
        int num4 = -25;
        long num5 = -45;
        System.out.println(num4 << 32);
        System.out.println(num5 << 64);
        System.out.println("=======================");
        System.out.println(Integer.toBinaryString(127));
    }
}
